<template>
  <div>
    <custom-form
      add-title="分配"
      :columns="columns"
      :rules="rules"
      v-bind="$attrs"
      v-on="$listeners"

    >
    </custom-form>
  </div>
</template>

<script>
import customFromMixin from '@/utils/mixin/custom-form'

export default {
  name: 'AllotRoom',
  mixins: [customFromMixin],
  data() {
    return {
      rules: {},
      // 列配置
      columns: [
        {
          name: '小区',
          field: 'housing_id',
          opts: {
            control: 'housing',
            name: 'name',
            required: true,
            reload: true,
            field: 'id'
          },
          type: 'select_table'

        },
        {
          name: '房型',
          field: 'type_name',
          required: true,
          opts: {
            control: 'roomType',
            name: 'name',
            reload: true,
            field: 'id'
          },
          type: 'select_table'

        },
        {
          name: '房间',
          field: 'room_id',
          opts: {
            control: 'room',
            name: 'name',
            required: true,
            query(formData, detail) {
              // console.log('输出了', formData)
              var query = {}
              query['filter[status]'] = 1
              query['type'] = 'valid'
              if (formData.housing_id) {
                query['filter[housing_id]'] = formData.housing_id
              }
              if (formData.type_name) {
                query['filter[room_type]'] = formData.type_name
              }

              return query
            },
            reload: true
          },
          type: 'select_table',
          visible(formData, detail) {
            // console.log('打印', formData)
            return formData.housing_id && formData.type_name
          }

        },
        { name: '入住时间', field: 'start_time', type: 'date', opts: { required: true } },
        { name: '租期', field: 'lease_mark', opts: { required: true } }
      ]
    }
  },
  watch: {},
  methods: {}
}
</script>

<style scoped>
</style>
